function allGroups = DG(fun, lowerBound, upperBound, n)
dims = 1 : n;
seps = {};
allGroups = {};
while ~isempty(dims)
    index = 1;
    i = dims(index);
    index = index + 1;
    group = [];
    group(end + 1) = i;
    while index <= length(dims)
        j = dims(index);
        index = index + 1;
        p1 = lowerBound .* ones(1, n);
        p2 = p1;
        p2(1, i) = upperBound;
        delta1 = fun(p1') - fun(p2');
        delta1 = delta1';       % 每一列是一个种群
        p1(1, j) = 0;
        p2(1, j) = 0;
        delta2 = fun(p1') - fun(p2');
        delta2 = delta2';
        if abs(delta1 - delta2) > 1 * 10 ^ (-3)
            group(end + 1) = j;
        end
    end
    isGroup = ismember(dims, group);    % 删除dims中group中的所有元素
    dims = dims(~isGroup);
    if length(group) == 1
        seps{end + 1} = group;
    else
        allGroups{end + 1} = group;
    end
end
allGroups = [allGroups, seps];
end

